package org.small.shop.phone.api;


import javax.servlet.MultipartConfigElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 系统启动项模块
 * 
 * @ClassName: AplictionConfig
 * @Description: 系统启动项模块
 * @author LQY(廖先生)
 * @date 2018年1月5日 下午4:27:27
 *
 */
@Configuration // 承认这个类是一个Java配置文件
@SpringBootApplication
@EnableScheduling // 开启定时任务
public class AplictionConfig extends SpringBootServletInitializer {

	private static Logger logger = LoggerFactory.getLogger(AplictionConfig.class);

	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(AplictionConfig.class);
	}

	public static void main(String[] args) throws Exception {
		logger.info("spring boots start");
		SpringApplication.run(AplictionConfig.class, args);
	}

	/**
	 * 文件上传配置
	 * 
	 * @return
	 */
	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		// 文件最大
		factory.setMaxFileSize("10240KB"); // KB,MB
		/// 设置总上传数据总大小
		factory.setMaxRequestSize("102400KB");
		return factory.createMultipartConfig();
	}

}
